import httpUtils from "../../../commons/utils/FeatchUtils";
import {basicUrl} from "../../../configs/DefaultConfig";

/**
 * @Description:
 * @Author: CHEHSHUANG
 * @Date: 2019/1/24
 */
//查询功能角色组
export const findFeatureRoleGroup = () => {
    return httpUtils.get(basicUrl+"/featureRoleGroup/findAll");
}
//查询功能角色
export const findFeatureRoleByGroupId = (roleGroupId=null) => {
    return httpUtils.get(basicUrl+"/featureRole/findByFeatureRoleGroup",{roleGroupId:roleGroupId});
}
//保存功能角色组
export const saveFeatureRoleGroup = (roleGroup={}) => {
    return httpUtils.postJson(basicUrl+"/featureRoleGroup/save",roleGroup);
}
export const deleteRoleGroup = (id="") => {
    return httpUtils.delete(basicUrl+"/featureRoleGroup/delete",id);
}
//保存功能角色
export const saveFeatureRole = (role={}) => {
    return httpUtils.postJson(basicUrl+"/featureRole/save",role);
}
//删除
export const deleteRole = (id="") => {
    return httpUtils.delete(basicUrl+"/featureRole/delete",id);
}
//查看用户
export const getUser = (featureRoleId="") => {
    return httpUtils.get(basicUrl+"/featureRole/getAssignedEmployeesByFeatureRole",{featureRoleId:featureRoleId});
}
//查看岗位
export const getPosition = (featureRoleId="") => {
    return httpUtils.get(basicUrl+"/featureRole/getAssignedPositionsByFeatureRole",{featureRoleId:featureRoleId});
}
export const listAssigned = (parentId="") => {
    return httpUtils.get(basicUrl+"/featureRoleFeature/getChildrenFromParentId",{parentId:parentId});
}
export const listUnAssigned = (parentId="") => {
    return httpUtils.get(basicUrl+"/featureRoleFeature/getUnassigned",{parentId:parentId});
}
//功能角色分配
export async function removeFeatureRoles(params={}){
    return httpUtils.delete(basicUrl+"/featureRoleFeature/removeRelationsByParam",JSON.stringify(params));
}
export async function insertFeatureRoles(params={}){
    return httpUtils.postJson(basicUrl+"/featureRoleFeature/insertRelationsByParam",JSON.stringify(params));
}
